/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * <p>Project: javase - Ex1
 * <p>Powered by webrx On 2021-11-24 09:06:48
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex1 {
    public static void main(String[] args) throws ParseException {
        //a-b 之间随机日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        var a = "2021-01-01 00:00:00";
        var d1 = sdf.parse(a).getTime();
        //System.out.printf("%1$tF %1$tT%n",946656000000l);

        var b = "2021-11-24 09:23:30";
        var d2 = sdf.parse(b).getTime();
        //System.out.printf("%1$tF %1$tT%n",1451577599000L);
        var r = new Random();

        // 0 - num
        var num = d2 - d1 + 1;
        var d3 = d1 + (long) (r.nextDouble() * num);
        System.out.printf("%1$tF %1$tT%n", d3);
    }
}
